//
//  SYNoNetView.m
//  siyanone
//
//  Created by LK-IOS on 2018/3/21.
//  Copyright © 2018年 LK-News. All rights reserved.
//

#import "SYNoNetView.h"

@interface SYNoNetView()


@property (nonatomic, strong)UIImageView *icon;
@property (nonatomic, strong)UILabel *tipLbl;
@property (nonatomic, strong)SYNoHeightedButton *loginBtn;

@end

@implementation SYNoNetView

- (instancetype)init
{
    if (self = [super init]) {
        self.backgroundColor = NumberColor(247, 247, 247);
        [self icon];
        [self tipLbl];
        [self loginBtn];
    }
    return self;
}

- (void)loginBtnDidSelected:(SYNoHeightedButton *)sender
{
    if (self.clickBlock) {
        self.clickBlock(YES);
    }
}

-(UIImageView *)icon
{
    if (!_icon) {
        _icon = [UIImageView new];
        _icon.image = [UIImage imageNamed:@"wuxinhao"];
        [self addSubview:_icon];
        [_icon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(isPhoneX? rateX812(60) : rate750(60));
            make.centerX.equalTo(self);
        }];
        
    }
    return _icon;
}



-(SYNoHeightedButton *)loginBtn
{
    if (!_loginBtn) {
        _loginBtn = [SYNoHeightedButton buttonWithType:UIButtonTypeCustom];
        [_loginBtn setTitleColor:[UIColor colorWithHexString:blueyGrey] forState:UIControlStateNormal];
        [_loginBtn setTitle:@"刷新页面" forState:UIControlStateNormal];
        _loginBtn.backgroundColor = self.backgroundColor;
        _loginBtn.layer.cornerRadius = 4;
        _loginBtn.layer.borderWidth = 1;
        _loginBtn.layer.borderColor = [UIColor colorWithHexString:blueyGrey].CGColor;
        
        [self addSubview:_loginBtn];
        [_loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.icon.mas_bottom).offset(30);
            make.centerX.equalTo(self);
            make.height.equalTo(isPhoneX ? @(rateX812(42)) : @(rate750(42)));
            make.width.equalTo(@(rate375(200)));
        }];
        [_loginBtn addTarget:self action:@selector(loginBtnDidSelected:) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return _loginBtn;
}

@end
